# Franka Servo Makefile

.PHONY: install dev-install test clean build upload-test upload format lint help

# 默认目标
help:
	@echo "Franka Servo 开发和构建命令:"
	@echo ""
	@echo "  install        - 安装包"
	@echo "  dev-install    - 开发模式安装包"
	@echo "  test           - 运行测试"
	@echo "  clean          - 清理构建文件"
	@echo "  build          - 构建包"
	@echo "  upload-test    - 上传到测试PyPI"
	@echo "  upload         - 上传到正式PyPI"
	@echo "  format         - 格式化代码"
	@echo "  lint           - 代码检查"
	@echo "  help           - 显示帮助信息"

# 安装包
install:
	pip install -r requirements.txt
	pip install .

# 开发模式安装
dev-install:
	pip install -r requirements.txt
	pip install -e ".[dev]"

# 运行测试
test:
	python -m pytest tests/ -v

# 清理构建文件
clean:
	rm -rf build/
	rm -rf dist/
	rm -rf *.egg-info/
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete

# 构建包
build: clean
	python setup.py sdist bdist_wheel
	twine check dist/*

# 上传到测试PyPI
upload-test: build
	twine upload --repository-url https://test.pypi.org/legacy/ dist/*

# 上传到正式PyPI
upload: build
	twine upload dist/*

# 格式化代码
format:
	black franka_servo/ tests/ examples/

# 代码检查
lint:
	flake8 franka_servo/ tests/ examples/
	mypy franka_servo/

# 完整的开发环境设置
setup-dev: dev-install
	@echo "开发环境设置完成！"
	@echo "运行 'make test' 来运行测试"
	@echo "运行 'make format' 来格式化代码"
